package tools

import (
	"gitee.com/igolang/imoney/internal/app/system/entities"
	"gitee.com/igolang/imoney/internal/app/system/entities/constants"
	"github.com/gin-gonic/gin"
)

func GetUserInfo(ctx *gin.Context) *entities.LoginUserInfo {
	result := &entities.LoginUserInfo{
		Permissions: make([]string, 0),
		Roles:       make([]string, 0),
	}
	val, ok := ctx.Get(constants.LoginUser)
	if !ok {
		return result
	}
	r, ok := val.(*entities.LoginUserInfo)
	if !ok {
		return result
	}

	return r
}
